Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: Fix ActivePlan crashing with self-joins #514

Merged

Conversation

akarnokd
Copy link
Collaborator

This PR fixes a crash due to key reuse in ActivePlan that prevents self-joins such as this:

var source = Observable.Range(1, 5);
Observable.When(
    source.And(source).Then((a, b) => a + b)
)
.Subscribe(Console.WriteLine);

Without the fix, there is a crash:

System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
System.Reactive.Joins.ActivePlan.AddJoinObserver(IJoinObserver joinObserver)
System.Reactive.Joins.ActivePlan`2..ctor(JoinObserver`1 first, JoinObserver`1 second, Action`2 onNext, Action onCompleted)
System.Reactive.Joins.Plan`3.Activate(Dictionary`2 externalSubscriptions, IObserver`1 observer, Action`1 deactivate)
System.Reactive.Linq.QueryLanguage.<>c__DisplayClass421_0`1.<When>b__0(IObserver`1 observer)

Note that I have generally little understanding of the Join Patterns so I'm not sure if this fix is actually legitimate in the context of the intended behavior of the Join Patterns beyond the fact that existing unit tests pass with the modification (locally).

@akarnokd akarnokd force-pushed the JoinPatternsAndSourceIdentityFix branch from 636ff38 to c0f3d2f Compare May 26, 2018 14:51
@clairernovotny clairernovotny merged commit f55707b into dotnet:master May 26, 2018
@akarnokd akarnokd deleted the JoinPatternsAndSourceIdentityFix branch May 26, 2018 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants